package com.ruoyi.produce.report.productTracing.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.produce.process.receiving.service.IReceivingReportService;
import com.ruoyi.produce.report.productTracing.service.IProductTracingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 产品追踪
 * 2022.1.2
 */
@RestController
@RequestMapping("/report/productTracing")
@Api(value = "产品追踪模块", tags = "产品追踪接口")
public class ProductTracingController extends BaseController {
    @Autowired
    private IProductTracingService productTracingService;
    @Autowired
    private IReceivingReportService receivingReportService;

    /**
     * 通过验收批号查询产品追溯信息
     * @return
     */
    @ApiOperation("通过验收批号查询产品追溯信息")
    @GetMapping("/info")
    public AjaxResult searchProductTracingById(@RequestParam String receivingReportId) {
        if (!StringUtils.isNotNull(receivingReportService.selectReceivingReportById(receivingReportId))) {
            return AjaxResult.error("该批号不存在，请重新输入");
        }
        return AjaxResult.success(productTracingService.searchProductTracingById(receivingReportId));
    }
}
